from flask import Flask
import os

def create_app():
    # 获取当前文件所在目录的父目录（项目根目录）
    template_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'templates'))
    static_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'static'))
    
    app = Flask(__name__,
                template_folder=template_dir,
                static_folder=static_dir)
    
    from app.routes import main
    app.register_blueprint(main)
    
    return app 